﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: Tuesday, April 08, 2014 5:21:29 PM
// Code is generated using templates: SD.TemplateBindings.Linq
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using SD.LLBLGen.Pro.LinqSupportClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

using TuanHuy.DAL;
using TuanHuy.DAL.EntityClasses;
using TuanHuy.DAL.FactoryClasses;
using TuanHuy.DAL.HelperClasses;
using TuanHuy.DAL.RelationClasses;

namespace TuanHuy.DAL.Linq
{
	/// <summary>Meta-data class for the construction of Linq queries which are to be executed using LLBLGen Pro code.</summary>
	public class LinqMetaData: ILinqMetaData
	{
		#region Class Member Declarations
		private IDataAccessAdapter _adapterToUse;
		private FunctionMappingStore _customFunctionMappings;
		private Context _contextToUse;
		#endregion
		
		/// <summary>CTor. Using this ctor will leave the IDataAccessAdapter object to use empty. To be able to execute the query, an IDataAccessAdapter instance
		/// is required, and has to be set on the LLBLGenProProvider2 object in the query to execute. </summary>
		public LinqMetaData() : this(null, null)
		{
		}
		
		/// <summary>CTor which accepts an IDataAccessAdapter implementing object, which will be used to execute queries created with this metadata class.</summary>
		/// <param name="adapterToUse">the IDataAccessAdapter to use in queries created with this meta data</param>
		/// <remarks> Be aware that the IDataAccessAdapter object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(IDataAccessAdapter adapterToUse) : this (adapterToUse, null)
		{
		}

		/// <summary>CTor which accepts an IDataAccessAdapter implementing object, which will be used to execute queries created with this metadata class.</summary>
		/// <param name="adapterToUse">the IDataAccessAdapter to use in queries created with this meta data</param>
		/// <param name="customFunctionMappings">The custom function mappings to use. These take higher precedence than the ones in the DQE to use.</param>
		/// <remarks> Be aware that the IDataAccessAdapter object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(IDataAccessAdapter adapterToUse, FunctionMappingStore customFunctionMappings)
		{
			_adapterToUse = adapterToUse;
			_customFunctionMappings = customFunctionMappings;
		}
	
		/// <summary>returns the datasource to use in a Linq query for the entity type specified</summary>
		/// <param name="typeOfEntity">the type of the entity to get the datasource for</param>
		/// <returns>the requested datasource</returns>
		public IDataSource GetQueryableForEntity(int typeOfEntity)
		{
			IDataSource toReturn = null;
			switch((TuanHuy.DAL.EntityType)typeOfEntity)
			{
				case TuanHuy.DAL.EntityType.AspnetApplicationsEntity:
					toReturn = this.AspnetApplications;
					break;
				case TuanHuy.DAL.EntityType.AspnetMembershipEntity:
					toReturn = this.AspnetMembership;
					break;
				case TuanHuy.DAL.EntityType.AspnetSchemaVersionsEntity:
					toReturn = this.AspnetSchemaVersions;
					break;
				case TuanHuy.DAL.EntityType.AspnetUsersEntity:
					toReturn = this.AspnetUsers;
					break;
				case TuanHuy.DAL.EntityType.CategoryEntity:
					toReturn = this.Category;
					break;
				case TuanHuy.DAL.EntityType.GalleriesEntity:
					toReturn = this.Galleries;
					break;
				case TuanHuy.DAL.EntityType.GalleryCategoryEntity:
					toReturn = this.GalleryCategory;
					break;
				case TuanHuy.DAL.EntityType.LanguageEntity:
					toReturn = this.Language;
					break;
				case TuanHuy.DAL.EntityType.ProductsEntity:
					toReturn = this.Products;
					break;
				case TuanHuy.DAL.EntityType.ProductsLanguageEntity:
					toReturn = this.ProductsLanguage;
					break;
				case TuanHuy.DAL.EntityType.ProjectCatogeryEntity:
					toReturn = this.ProjectCatogery;
					break;
				case TuanHuy.DAL.EntityType.ProjectsEntity:
					toReturn = this.Projects;
					break;
				case TuanHuy.DAL.EntityType.ProjectsLanguageEntity:
					toReturn = this.ProjectsLanguage;
					break;
				default:
					toReturn = null;
					break;
			}
			return toReturn;
		}

		/// <summary>returns the datasource to use in a Linq query when targeting AspnetApplicationsEntity instances in the database.</summary>
		public DataSource2<AspnetApplicationsEntity> AspnetApplications
		{
			get { return new DataSource2<AspnetApplicationsEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting AspnetMembershipEntity instances in the database.</summary>
		public DataSource2<AspnetMembershipEntity> AspnetMembership
		{
			get { return new DataSource2<AspnetMembershipEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting AspnetSchemaVersionsEntity instances in the database.</summary>
		public DataSource2<AspnetSchemaVersionsEntity> AspnetSchemaVersions
		{
			get { return new DataSource2<AspnetSchemaVersionsEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting AspnetUsersEntity instances in the database.</summary>
		public DataSource2<AspnetUsersEntity> AspnetUsers
		{
			get { return new DataSource2<AspnetUsersEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting CategoryEntity instances in the database.</summary>
		public DataSource2<CategoryEntity> Category
		{
			get { return new DataSource2<CategoryEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting GalleriesEntity instances in the database.</summary>
		public DataSource2<GalleriesEntity> Galleries
		{
			get { return new DataSource2<GalleriesEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting GalleryCategoryEntity instances in the database.</summary>
		public DataSource2<GalleryCategoryEntity> GalleryCategory
		{
			get { return new DataSource2<GalleryCategoryEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting LanguageEntity instances in the database.</summary>
		public DataSource2<LanguageEntity> Language
		{
			get { return new DataSource2<LanguageEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductsEntity instances in the database.</summary>
		public DataSource2<ProductsEntity> Products
		{
			get { return new DataSource2<ProductsEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductsLanguageEntity instances in the database.</summary>
		public DataSource2<ProductsLanguageEntity> ProductsLanguage
		{
			get { return new DataSource2<ProductsLanguageEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProjectCatogeryEntity instances in the database.</summary>
		public DataSource2<ProjectCatogeryEntity> ProjectCatogery
		{
			get { return new DataSource2<ProjectCatogeryEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProjectsEntity instances in the database.</summary>
		public DataSource2<ProjectsEntity> Projects
		{
			get { return new DataSource2<ProjectsEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProjectsLanguageEntity instances in the database.</summary>
		public DataSource2<ProjectsLanguageEntity> ProjectsLanguage
		{
			get { return new DataSource2<ProjectsLanguageEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		
		#region Class Property Declarations
		/// <summary> Gets / sets the IDataAccessAdapter to use for the queries created with this meta data object.</summary>
		/// <remarks> Be aware that the IDataAccessAdapter object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public IDataAccessAdapter AdapterToUse
		{
			get { return _adapterToUse;}
			set { _adapterToUse = value;}
		}

		/// <summary>Gets or sets the custom function mappings to use. These take higher precedence than the ones in the DQE to use</summary>
		public FunctionMappingStore CustomFunctionMappings
		{
			get { return _customFunctionMappings; }
			set { _customFunctionMappings = value; }
		}
		
		/// <summary>Gets or sets the Context instance to use for entity fetches.</summary>
		public Context ContextToUse
		{
			get { return _contextToUse;}
			set { _contextToUse = value;}
		}
		#endregion
	}
}